package guiCode;

import java.sql.SQLException;

import javax.swing.JLabel;
import javax.swing.table.DefaultTableCellRenderer;

import teacher.getassignment;
import flexibility.CachedRowSetTableModel;
import flexibility.userData;
import gui.TeacherMainMenuGUI;
import gui.assignmentsGUI;
import gui.studGradeAssGUI;
import basic.ClientConsole;
import teacher.getstudGradeAss;

import com.sun.rowset.CachedRowSetImpl;

public class studGradeAsscode {
	private studGradeAssGUI sga;
	String assID;//set to the selected ass
	public userData T_Data = new userData();
	public TeacherMainMenuGUI tmm ;
	public ClientConsole teacherConnection=TeacherMainMenuCode.getTeacherConnection();
	public CachedRowSetImpl rs;
	int myID=TeacherMainMenuCode.getMyID();
	private CachedRowSetTableModel data;
	
	
	public CachedRowSetImpl getstudGradeAss(String s1) throws SQLException{
		getstudGradeAss sgas = new getstudGradeAss();
		rs=sgas.getstudGrade(teacherConnection, rs, T_Data, myID,s1);//s1=ass id
		//System.out.println(rs.getString(1));
		return rs;
	}
	public void update(studGradeAssGUI sga, CachedRowSetImpl crs) {
		try {
			sga.table_1.setModel(data = new CachedRowSetTableModel(crs));
			DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
			centerRenderer.setHorizontalAlignment(JLabel.CENTER);
			for (int i = 0; i < sga.table_1.getColumnCount(); i++)
				sga.table_1.getColumnModel().getColumn(i)
						.setCellRenderer(centerRenderer);
			sga.table_1.setEnabled(true);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public void setAssId(String s1)
	{
		assID=s1;	
	}
	public String getAssID() {
		// TODO Auto-generated method stub
		return assID;
	}

}
